import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import form from '@/views/form.vue'
export const constantRoutes = [
  {
    path: '/',
    redirect: '/form'
  },
  {
    name: 'form',
    path: '/form',
    component: form
  },
  {
    name: 'table',
    path: '/table',
    component: () => import('@/views/table.vue')
  },
  {
    name: 'editTable',
    path: '/editTable',
    component: () => import('@/views/editTable.vue')
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
